<?php
namespace app\model;
class UserCompanyInvite extends \think\Model{
    public $table="user_company_invite";


    /**
     * 添加 一条 用户对指定用户发送指定工作邀请记录
     * @param $data
     * @return int|string
     */
    function addInvite($data){
        $UserCompany=new UserCompany();
        $Job=new Job();
        $j_arr=$Job->get_job_info_by_id($data['job_id']);


        $c_arr=$UserCompany->get_user_company($data['company_user_id']);



        $data2['user_id']=$data['user_id'];


        $data2['created_at']=cur_time();
        $data2['content']=$data['content'];
        $data2['job_id']=$data['job_id'];
        $data2['company_user_id']=$data['company_user_id'];



        $data2['company_id']=$c_arr['id'];
        $data2['job_name']=$j_arr['job_name'];
        $data2['company_name']=$c_arr['company_name'];

        return $this->insertGetId($data2);
    }

    /**
     * 根据用户ID，返回已经接受到的邀请记录
     * @param $user_id
     */
    function get_has_get_invite_log($user_id){
        $o=$this->where(['user_id'=>$user_id])->order("id","desc")->select();
        $arrs=object2array($o);
        $UserCompany=new UserCompany();

        return $arrs;
    }
}